<?php
class Loguin extends CI_Controller{
	function __construct(){
		parent::__construct();
		$this->load->helper("form");
		$this->load->library("form_validation");
		
	}
	function index(){
		$data['main_content']='user/loguin';
		$data['textocabecera']='Logueo de Usuario';
		$data['title']='Logueo de Usuario';
		$this->load->view('includes/template',$data);
	}
	function logued(){
		$this->form_validation->set_rules('username', 'Nombre de Usuario', 'required|trim|min_length[3]|callback__verificarusuario');
		$this->form_validation->set_rules('email', 'E-mail', 'trim|valid_email|required');
		$this->form_validation->set_rules('repassword', 'Contraseña', 'required|md5');
		$this->form_validation->set_rules('repassword', 'Confirmar Contraseña', 'required|matches[password]|md5');
		$this->form_validation->set_message('required','El campo es requerido');
		$this->form_validation->set_message('min_length','Campo mínimo 6 caracteres');
		$this->form_validation->set_message('_verificarusuario','El Nombre de Usuario ya existe.');
		if ($this->form_validation->run() == FALSE)
		{
			$this->index();
		}
		else
		{
			echo $this->input->post('username');
		}
		
	}
	function _verificarusuario($value){
		if($value=='hola'){
			return false;}
		else{
			return true;	
		}
		
	}
}
	
?>